<%@ page import="com.cinsea.common.Env" %>
<%@ page import="java.util.List" %>
<%@ page import="com.cinsea.msg.MessageProducer" %>
<%@ page import="com.cinsea.msg.Message" %>
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ include file="/common/common.jsp" %>
<%--
  ~ Copyright (c) 2011. 晨熹软件版权所有。
  --%>

<%
    response.setHeader("cache-control", "no-cache");
    response.setHeader("pragma", "no-cache");
    response.setHeader("expires", "Mon 1 Jan 1990 00:00:00 GMT");
    String action = StringUtil.null2String(request.getParameter("action"));
    MessageProducer messageProducer = (MessageProducer) Env.getBean("messageProducer");
    JdbcDao jdbcDao=(JdbcDao)Env.getBean("jdbcDao");
    String humanids = StringUtil.null2String(request.getParameter("humanids"));//学员
    String receivers = "";
    ArrayList<String> humanlist= StringUtil.string2ArrayList(humanids,",");
    String sql;
    String tablename="ut_students";
    if(action.equals("jnjd"))   tablename="ut_students";
    if(action.equals("pxyf"))   tablename="ut_students2";
    for(String xyid:humanlist){
        sql="select mobile from "+tablename+" where processid=? and mobile is not null";
        List result=jdbcDao.queryForList(sql,new Object[]{xyid});
        if(result.size()>0){
            Map map=(Map)result.get(0);
            String mobileno=(String)map.get("mobile");
            if(!StringUtil.isEmpty(mobileno))  receivers +=","+mobileno;
        }
        if(receivers.startsWith(",")) receivers=receivers.substring(1);
    }
    if (!StringUtil.isEmpty(receivers)) {
    String msgcontent = StringUtil.null2String(request.getParameter("msgcontent"));
    String sender = Env.getRemoteUser().getCurrentuserid(); //当前用户的id;
    Message msg = new Message(Message.MESSAGE_TYPE_SMS, sender, receivers, msgcontent);
    messageProducer.send(msg);
      }

    out.write("sucess");

%>
